package com.jhg.drgclinicalpathway.dao;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jhg.drgclinicalpathway.domain.Clinicalpathwaydetail;
import com.jhg.drgclinicalpathway.domain.V临床路径项目;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ClinicalpathwaydetailDao extends BaseMapper<Clinicalpathwaydetail>{
    @Select({
            "<script>",
            "select top 1 a.* from LJ_临床路径明细 a left join V临床路径项目 b on a.项目ID=b.ID " +
            "where a.版本id='${bbid}' and b.类型='${lx}' ORDER BY 序号 desc",
            "</script>"
    })
    public List<Clinicalpathwaydetail> getLcljmx(@Param("bbid") String bbid,@Param("lx") String lx);


    @Select({
            "<script>",
            "select top 1 a.* from LJ_临床路径明细 a " ,
            " where a.版本id='${bbid}' and a.项目ID='${xmid}' ORDER BY 序号 desc",
            "</script>"
    })
    public List<Clinicalpathwaydetail> getLcljmxbyXmid(@Param("bbid") String bbid,@Param("xmid") String xmid);

    @Override
    int update(Clinicalpathwaydetail entity, Wrapper<Clinicalpathwaydetail> updateWrapper);


    @Update({"update LJ_临床路径明细 set 序号=序号+1 where 版本id='${bbid}' and 序号>${xh}"})
    public int updateXh(@Param("bbid") String bbid,@Param("xh") int xh);
}
